import 'dart:io';

import 'package:flutter/material.dart';

class TImage extends StatefulWidget {
  final String url;
  final double width;
  final double height;

  final BoxFit fit;

  TImage(this.url, this.width, this.height,[this.fit=BoxFit.cover]);



  @override
  _TImageState createState() {
    return _TImageState();
  }
}

class _TImageState extends State<TImage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {

     if(widget.url.startsWith("http")){
       return   Image.network(widget.url,width: widget.width,height: widget.height,fit: widget.fit,);

    } else if(widget.url.startsWith("assets")){
       return   Image.asset(widget.url,width: widget.width,height: widget.height,fit: widget.fit,);

     }else{
       return   Image.file(File(widget.url),width: widget.width,height: widget.height,fit: widget.fit,);

    };
  }
}